Skip to content

Refactor pnpm provider argument handling and validation logic#36

Closed
pirate wants to merge 2 commits into
mainfrom
claude/exciting-volta-4ABNy
Closed

Refactor pnpm provider argument handling and validation logic#36
pirate wants to merge 2 commits into
mainfrom
claude/exciting-volta-4ABNy

Conversation

@pirate
Copy link
Copy Markdown
Member

@pirate pirate commented May 29, 2026

Summary

This PR refactors the argument handling and validation logic in the pnpm binary provider's install and update handlers to improve code clarity and maintainability.

Key Changes

  • Simplified parameter defaults: Moved default value assignments for postinstall_scripts and min_release_age from ternary expressions to explicit if-statements for better readability
  • Fixed argument checking logic: Removed "--loglevel=error" from the tuple being checked when validating for --ignore-scripts and --config.minimumReleaseAge flags, as these checks should only inspect user-provided install_args
  • Removed redundant None checks: Eliminated unnecessary min_release_age is not None checks since the value is guaranteed to be set before use
  • Improved code formatting: Simplified multi-line list and conditional expressions for better readability
  • Extracted variable: In default_update_handler, extracted the verb selection ("add" vs "update") into a named variable for clarity

Implementation Details

The refactoring maintains the same functional behavior while making the code more maintainable:

  • Parameter validation now follows a clearer pattern: check if None, assign default, then apply conditional logic
  • The argument checking logic is now more precise by only examining actual install arguments rather than including hardcoded flags
  • Both default_install_handler and default_update_handler receive consistent refactoring treatment

https://claude.ai/code/session_013Vip4GWbvDAjVCx1thr4bs


Summary by cubic

Refactors pnpm provider install/update handlers to simplify argument handling and make validation clearer, with no behavior changes. Cleans up defaults, tightens arg checks, and improves readability.

  • Refactors
    • Set explicit defaults for postinstall_scripts and min_release_age.
    • Check only user install_args for --ignore-scripts and --config.minimumReleaseAge; removed dead --loglevel=error from checks.
    • Dropped redundant None checks; kept positive-age guard.
    • Simplified list/condition formatting; extracted update verb to verb.
    • Applied the same cleanup to both install and update paths.

Written for commit a4a7e9c. Summary will update on new commits.

Review in cubic

claude added 2 commits May 28, 2026 05:56
Pull the duplicated install/update bodies into shared
_build_mutation_args / _apply_min_version / _install_args_have_option
helpers, matching the npm provider's pattern. Also drops the dead
'--loglevel=error' entry that was being prepended to install_args
inside arg-presence checks but could never match the searched flag.
Fold the _build_mutation_args / _apply_min_version /
_install_args_have_option helpers back into the install and update
handlers directly. They were only used in two call sites each, and the
indirection didn't pay for itself.
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@pirate pirate closed this May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants